package com.example.demo.gateway.repository;

import com.example.demo.gateway.entity.GatewayRoute;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Repository
public interface GatewayRouteRepository extends ReactiveCrudRepository<GatewayRoute, Long> {

    // additional custom query methods go here
    @Query("SELECT * FROM gateway_route ORDER BY orders LIMIT :page,:size")
    Flux<GatewayRoute> findPage(int page, int size);

    Mono<GatewayRoute> findByRname(String rname);

    Mono<Void> deleteByRname(Mono<String> rname);

//    @Query("INSERT INTO gateway_route (id, description, uri, predicates, filters, orders) VALUES (:id,:description, :uri, :predicates, :filters, :orders)")
//    Mono<GatewayRoute> insert(String id, String description,String uri, String predicates, String filters, Integer orders);
}